package com.hspedu.springcloud;

import java.util.function.Function;

/**
 * @author 韩顺平
 * @version 1.0
 */
public class T1 {

    public static void main(String[] args) {

        //这是lambda表达式的第一种形式
        //Dog dog = hi("小花猫", (String str) -> {
        //    Cat cat = new Cat();
        //    cat.setName(str);
        //    return cat;
        //});

        //对上面的lambda表达式进行简写
        //Dog dog = hi("小花猫", str -> {
        //    Cat cat = new Cat();
        //    cat.setName(str);
        //    return cat;
        //});
        //对上面的lambda表达式进行简写
        //Dog dog = hi("小花猫", str -> {
        //    return new Cat(str);
        //});

        //对上面的lambda表达式进行简写
        Dog dog = hi("小黄猫", r -> new Cat(r));
        System.out.println(dog);
    }

    /**
     * public Builder route(String id, Function<PredicateSpec, Route.AsyncBuilder> fn) {
     * Route.AsyncBuilder routeBuilder = fn.apply(new RouteSpec(this).id(id));
     * add(routeBuilder);
     * return this;
     * }
     * routes.route("member_route04", r -> r.path("/member/get/**")
     * .uri("http://localhost:10000"))
     */

    //模拟把 Cat ->Dog
    public static Dog hi(String str, Function<String, Cat> fn) {
        Cat cat = fn.apply(str);
        Dog dog = new Dog();
        dog.setName(cat.getName() + " ~变成了小狗名");
        return dog;
    }

}

class Dog {
    private String name;

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                '}';
    }
}

class Cat {

    public Cat() {

    }

    public Cat(String name) {
        this.name = name;
    }

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}

class Hsp {


}
